<?php 
	include_once '../../../include/inc_session.php';	

	if(isset($_GET['Identifiant_personne']) && !empty($_GET['Identifiant_personne']))
	{ // Vérifier si Identifiant_personne est passé en paramètre
		$idPersonne = $_GET['Identifiant_personne'];
	}
	$idRole = $_GET['idrole'];
	$idContrat = $_GET['idcontrat'];
	
	$oAdresse = new dataObject_adresse();
	
	$aAdresses = $oAdresse->adresse_getActiveListForPersonne($idPersonne);
	
	if(isset($_GET['msg']) && $_GET['msg']=='1')
		$oForm->ajouterErreur(adresse_au_moins_un);
		
	if(isset($_GET['msg']) && $_GET['msg']=='supp')
		$oForm->ajouterErreur(adresse_deleted);
		
	if(isset($_GET['msg']) && $_GET['msg']=='no')
		$oForm->ajouterErreur(adresse_no_delete);
		
	if(isset($_GET['msg']) && $_GET['msg']=='pbm')
		$oForm->ajouterErreur(adresse_supp_pbm);

	$nommodule2="Liste des adresses";
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=8" />
			<title>Adresse</title>
			<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]-->
 
			<script language="Javascript">
            <!--
                function modifier(choix)
            {
                    var modifAct = document.getElementById("modifAct");
					var suppAct = document.getElementById("suppAct");

			        modifAct.href = 'modadresse.php?Identifiant_personne=<?php echo $_GET['Identifiant_personne']; ?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>&Identifiant_adresse=' + choix ;
			        suppAct.href = 'modadresse.php?Identifiant_personne=<?php echo $_GET['Identifiant_personne']; ?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>&Identifiant_adresse=' + choix + '&supp=1' ;
             }
            //-->
            </script>
	</head>
<body>
<div id="sf_menu1">
	<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>

</div>


<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>
<!--/***************************************/-->
	<div class="imgleft"></div>
	<div class="imgmiddle">
		<div class="btn">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="btn1">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $nommodule2; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="cleared"></div>
		<table class="tab_liste ns0">
		  <tr id="niv1">
		  	<td class="td1">&nbsp;</td>
		    <td class="td2">TYPE</td>
		    <td class="td3">ADRESSE</td>
		  </tr>
		</table>
    	<div class="content_table bright">
			<table class="tab_list">
<?php 
	if (count($aAdresses) > 0) 
	{ // Show if recordset not empty 
		foreach ($aAdresses as $i => $aAdresse)
		{
?>
    <tr <?php if($i%2==0) echo 'class="colorligne"'; ?>>
      <td class="td1">
      	<input onClick="modifier(this.value);" type="radio" name="choix" id="choix" value="<?php echo $aAdresse['Identifiant_adresse']; ?>" />
      </td>
      <td class="td2"><?php echo dataObject_elementdico::elementdico_getNomFromCode($aAdresse['Type_adresse'], dataObject_dictionnaire::TYPE_ADRESSE); ?></td>
      <td class="td3">
			<?php echo stripslashes($aAdresse['Ligne1_adresse'])." ".stripslashes($aAdresse['Ligne2_adresse'])." ".stripslashes($aAdresse['Ligne3_adresse']); ?>
      </td>
    </tr>
    <?php 
		}
	}
	?>
</table>
		</div>
						<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a href="insertadresse.php?Identifiant_personne=<?php echo $_GET['Identifiant_personne']?>&idcontrat=<?php echo $idContrat; ?>&idrole=<?php echo $idRole; ?>">Créer</a></span><span class="btright"></span></div>
						<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a id="modifAct" href="#">Modifier</a></span><span class="btright"></span></div>
						<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a id="suppAct" href="#">Supprimer</a></span><span class="btright"></span></div>
	
	</div>
	<div class="imgright"></div>
	<div class="cleared"></div>
	<!--/***************************************/-->
<?php
if(isset($_SESSION['visu']))
		$sUrlRetour = "../../changecouverture/intervenant_edit.php?Identifiant_personne=".$_GET['Identifiant_personne']."&idcontrat=".$idContrat."&idrole=".$idRole;
	else $sUrlRetour = "../edit_personne.php?Identifiant_personne=".$_GET['Identifiant_personne']."&idcontrat=".$idContrat."&idrole=".$idRole;
?>
<div class="bt1">
	<a href="<?php echo $sUrlRetour?>">
    	<span class="btleft"></span>
        <span class="btmiddle">Retour</span>
        <span class="btright"></span>
    </a>
</div>

</body>
</html>
<?php
include_once PATH_INCLUDE.'inc_pied_page.php';

?>